#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int Bitstr2ByteArr(unsigned char * bs, unsigned char * ba)
{
        int blen = strlen(bs);
        int t,i=0;
        int sum=0,tag;

        t = blen/8;
        while(t>0)
        {
            for(i=0;i<8;i++)
            {
                blen--;
                if(bs[blen] == '1') sum = sum + pow(2,tag);
                tag++;
            }
            printf("sum:%02x\n",sum);
            t--;
            tag=0;
            sum=0;
        }
        if(t==0)
        {
            blen--;
            for(;blen>=0;blen--)
            {
                if(bs[blen] == '1') sum = sum + pow(2,tag);
            }
            printf("sum:%02x\n",sum);
        }

}
int ByteArr2Bitstr(unsigned char * ba, unsigned char * bs);

int main()
{
    unsigned char* bs = "0101110010101101";
    unsigned char* ba;

    Bitstr2ByteArr(bs,ba);
}



